package cn.yz.fresh.controller;


import cn.yz.fresh.pojo.Category;
import cn.yz.fresh.pojo.Grade;
import cn.yz.fresh.pojo.Group;
import cn.yz.fresh.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Kim昌完 on 2017/8/26.
 */
@Controller
@RequestMapping("indexResource")
public class IndexController {
    private INavigateService navigateServiceImpl;
    private IGradeService gradeServiceImpl;
    private IGoodsService goodsServiceImpl;
    private ICategoryService categoryServiceImpl;
    private IGroupService  groupServiceImpl;
    private HashMap<Grade,Map> gradeMap;
    private  HashMap<Category,List> categoryMap;
    private List<Group> groupList;
    @RequestMapping(value = "navigateResource")
    public HashMap<Grade,Map> navigateResource(){
        List<Grade> grades = gradeServiceImpl.queryAll();

        for (Grade grade : grades) {
            List<Category> categoryList =categoryServiceImpl.queryAll(grade);
            for (Category category : categoryList) {
                groupList = groupServiceImpl.queryAll(category);
                categoryMap.put(category,groupList);
                gradeMap.put(grade,categoryMap);
            }
        }
        return gradeMap;
    }

    public INavigateService getNavigateServiceImpl() {
        return navigateServiceImpl;
    }

    public void setNavigateServiceImpl(INavigateService navigateServiceImpl) {
        this.navigateServiceImpl = navigateServiceImpl;
    }

    public IGradeService getGradeServiceImpl() {
        return gradeServiceImpl;
    }

    public void setGradeServiceImpl(IGradeService gradeServiceImpl) {
        this.gradeServiceImpl = gradeServiceImpl;
    }

    public IGoodsService getGoodsServiceImpl() {
        return goodsServiceImpl;
    }

    public void setGoodsServiceImpl(IGoodsService goodsServiceImpl) {
        this.goodsServiceImpl = goodsServiceImpl;
    }

    public ICategoryService getCategoryServiceImpl() {
        return categoryServiceImpl;
    }

    public void setCategoryServiceImpl(ICategoryService categoryServiceImpl) {
        this.categoryServiceImpl = categoryServiceImpl;
    }

    public IGroupService getGroupServiceImpl() {
        return groupServiceImpl;
    }

    public void setGroupServiceImpl(IGroupService groupServiceImpl) {
        this.groupServiceImpl = groupServiceImpl;
    }
}
